import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestComponent;

import java.time.LocalDateTime;
import java.util.Calendar;
import java.util.TimeZone;

@SpringBootTest
public class Demo {
    @Test
    public void test01(){
        //Java获取当前日期的前一个月,前一天时间
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.MONTH, -1);//得到前一个月

        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH) + 1;
        int date = calendar.get(Calendar.DATE);
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        int min = calendar.get(Calendar.MINUTE);
        System.out.println("DATA:"+year+"-"+month+"-"+date+":"+hour+"-"+min);
    }
}
